<template>
	<view class="news">
		<news-item @itemClick="goDetail" :list="newsList"></news-item>
	</view>
</template>

<script>
	import newsItem from '../../components/news-item/news-item.vue'
	export default {
		data() {
			return {
				newsList: []
			}
		},
		methods: {
			async getNews () {
				const res = await this.$myRequest({
					url: '/api/news/getNewsList'
				})
				console.log("newsList",res.data)
				let temp=res.data.data
				temp.forEach(item=>{
					this.newsList.push({
						id:item.id,
						// img_url:'/upload/newsImg/test.png',
						img_url:item.imgUrl,
						title:item.title,
						add_time:item.addTime,
						click:item.click
					})
				})
			},
			goDetail (id) {
				uni.navigateTo({
					url: '/pages/news-detail/news-detail?id='+id
				})
			}
		},
		components: {"news-item":newsItem},
		onLoad () {
			this.getNews()
		}
	}
</script>

<style lang="scss">
	.news{
		padding: 30px 0;
	}
</style>
